# -*- encoding: utf-8 -*-
"""

PyCharm 23分块图的绘制
2024年 11月 03日 15:32
coded by wenyang
文件的主要内容


"""
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl


def main():
    mpl.rcParams["font.sans-serif"] = ["SimHei"]
    mpl.rcParams["axes.unicode_minus"] = False
    x = np.arange(5)
    y = np.array([6, 10, 4, 5, 1])
    y1 = np.array([2, 6, 3, 8, 5])
    bar_width = 0.3
    tick_label = ["A", "B", "C", "D", "E"]
    # 绘制分块图
    plt.bar(x, y, bar_width, color = "c", align = "center", label = "班级A", alpha = 0.5)
    plt.bar(x + bar_width, y1, bar_width, color = "b", align = "center", label = "班级B", alpha = 0.5)
    plt.legend()
    plt.xlabel("测试的难度")
    plt.ylabel("试卷的份数")
    plt.xticks(x + bar_width / 2, tick_label)
    plt.legend()
    plt.show()


if __name__ == "__main__":
    main()
